# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

import os


import logging
logger=logging.getLogger(__name__)




class PubresPipeline(object):
    def process_item(self, item, spider):
        # logger.warning('进入流水线')
        with open(os.getcwd()+r'\PubRes\results\{}-{}.txt'.format(item['province'],item['stamp']),'a+',encoding='utf-8') as f:
            f.write(item['province'])
            f.write('#')
            f.write(item['classify'])
            f.write('#')
            f.write(item['title'])
            f.write('#')
            f.write(item['content'])
            f.write('#')
            f.write(item['time'])
            f.write('#')
            f.write(item['url'])
            f.write('\n')

        return item
